<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <jsp:include page="WEB-INF/head.jsp"></jsp:include>
    <script type="text/javascript">
        function show(uid) {
            var r = confirm("确定删除?");
            if (r) {
                location.href = "${pageContext.request.contextPath}/contactServlet?action=delete&id=" + uid;
            } else {

            }
        }
    </script>
</head>

<body>

<!--布局方式-->
<div class="container">
    <!--行-->
    <div class="row">
        <h3 style="text-align: center">用户信息列表</h3>

        <div class="navbar navbar-default navbar-fixed-top">
            <a class="navbar-brand" href="#">查询</a>
            <form class="navbar-form navbar-left" role="search" action="./contactServlet" method="get">
                <input type="hidden" name="action" value="queryForCondition">
                <div class="form-group">
                    <input type="text" name="nameLike" class="form-control" placeholder="姓名">
                </div>
                <div class="form-group">
                    <input type="number" name="fromAge" class="form-control" value="1" placeholder="大于年龄">
                </div>

                <div class="form-group">
                    <input type="number" name="toAge" class="form-control" value="100" placeholder="小于年龄">
                </div>

                <button type="submit" class="btn btn-default">搜索</button>
            </form>
        </div>

        <table border="1" class="table table-bordered table-hover table-striped">
            <tr class="success">
                <th>编号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>籍贯</th>
                <th>QQ</th>
                <th>邮箱</th>
                <th>生日</th>
                <th>操作</th>
            </tr>
            <c:forEach var="user" items="${pagelist.items}" varStatus="status">
                <tr>
                    <th>${status.count}</th>
                    <th>${user.name}</th>
                    <th>${user.sex}</th>
                    <th>${user.age}</th>
                    <th>${user.address}</th>
                    <th>${user.qq}</th>
                    <th>${user.email}</th>
                    <th>${user.createDate}</th>
                    <th>
                        <a class="btn btn-primary"
                           href="${pageContext.request.contextPath}/contactServlet?action=updateDispatcher&id=${user.id}">修改</a>
                        <a class="btn btn-danger" onclick="show(${user.id})">删除</a>
                    </th>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="9" align="center">
                    <ul class="pagination pagination-lg text-center">
                        <li><a href="${pageContext.request.contextPath}/contactServlet?action=queryAll&pageNo=1">上一页</a>
                        </li>
                        <c:forEach begin="1" end="${pagelist.pageTotal}" var="cout">
                            <c:if test="${cout==pagelist.pageNo}">
                                <li class="active"><a href="#">${pagelist.pageNo}</a></li>
                            </c:if>
                            <c:if test="${cout!=pagelist.pageNo}">
                                <li>
                                    <a href="${pageContext.request.contextPath}/contactServlet?action=queryAll&pageNo=${cout}">${cout}</a>
                                </li>
                            </c:if>
                        </c:forEach>
                        <li>
                            <a href="${pageContext.request.contextPath}/contactServlet?action=queryAll&pageNo=${pagelist.pageTotal}">下一页</a>
                        </li>
                    </ul>
                </td>
            </tr>
            <tr>
                <td colspan="9" align="center">
                    <a class="btn btn-primary btn-group-justified"
                       href="${pageContext.request.contextPath}/addcontact.jsp">增加联系人</a>
                </td>
            </tr>
        </table>

    </div>
</div>
</body>
<jsp:include page="WEB-INF/footer.jsp"></jsp:include>
</html>